﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using WPFExcelReport.Helpers;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class UIGABEW : ViewBase
    {
        
        public VGABEW TMV
        {
            get
            {
                return (VGABEW)MV;
            }
        }
        
        #region ==CONES===========
        public static readonly DependencyProperty CONESProperty = DependencyProperty.Register("CONES",
            typeof(int), typeof(UIGABEW),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnCONESChanged));
        public int CONES
        {
            get
            {
                return (int)GetValue(CONESProperty);
            }
            set
            {
                SetValue(CONESProperty, value);
            }
        }
        private static void OnCONESChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGABEW;
            if (src != null)
            {
                src.CONES = (int)e.NewValue;
            }
        }
        #endregion

        #region ==TARA===========
        public static readonly DependencyProperty TARAProperty = DependencyProperty.Register("TARA",
            typeof(double), typeof(UIGABEW),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTARAChanged));
        public double TARA
        {
            get
            {
                return (double)GetValue(TARAProperty);
            }
            set
            {
                SetValue(TARAProperty, value);
            }
        }
        private static void OnTARAChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGABEW;
            if (src != null)
            {
                src.TARA = (double)e.NewValue;
            }
        }
        #endregion
        
        #region ==BOX===========
        public static readonly DependencyProperty BOXProperty = DependencyProperty.Register("BOX",
            typeof(int), typeof(UIGABEW),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBOXChanged));
        public int BOX
        {
            get
            {
                return (int)GetValue(BOXProperty);
            }
            set
            {
                SetValue(BOXProperty, value);
            }
        }
        private static void OnBOXChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGABEW;
            if (src != null)
            {
                src.BOX = (int)e.NewValue;
            }
        }
        #endregion
        #region ==QTY===========
        public static readonly DependencyProperty QTYProperty = DependencyProperty.Register("QTY",
            typeof(double), typeof(UIGABEW),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnQTYChanged));
        public double QTY
        {
            get
            {
                return (double)GetValue(QTYProperty);
            }
            set
            {
                SetValue(QTYProperty, value);
            }
        }
        private static void OnQTYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGABEW;
            if (src != null)
            {
                src.QTY = (double)e.NewValue;
            }
        }
        #endregion
        #region ==MU===========
        public static readonly DependencyProperty MUProperty = DependencyProperty.Register("MU",
            typeof(string), typeof(UIGABEW),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnMUChanged));
        public string MU
        {
            get
            {
                return (string)GetValue(MUProperty);
            }
            set
            {
                SetValue(MUProperty, value);
                OnMUChg();
            }
        }
        private static void OnMUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGABEW;
            if (src != null)
            {
                src.MU = (string)e.NewValue;
            }
        }
        public virtual void OnMUChg()
        { }
        #endregion
        #region ==PARTIE===========
        public static readonly DependencyProperty PARTIEProperty = DependencyProperty.Register("PARTIE",
            typeof(string), typeof(UIGABEW),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPARTIEChanged));
        public string PARTIE
        {
            get
            {
                return (string)GetValue(PARTIEProperty);
            }
            set
            {
                SetValue(PARTIEProperty, value);
                OnPARTIEChg();
            }
        }
        private static void OnPARTIEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGABEW;
            if (src != null)
            {
                src.PARTIE = (string)e.NewValue;
            }
        }
        public virtual void OnPARTIEChg()
        { }
        #endregion
        #region ==dwZU===========
        public static readonly DependencyProperty dwZUProperty = DependencyProperty.Register("dwZU",
        typeof(DataRow), typeof(UIGABEW),
        new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwZUChanged));

        public DataRow dwZU
        {
            get
            {
                return (DataRow)GetValue(dwZUProperty);
            }
            set
            {
                SetValue(dwZUProperty, value);
             }
        }
        private static void OdwZUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGABEW;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwZU = row;
            }
        }
        #endregion
        public UIGABEW()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VGABEW();
            DataContext = MV;
         }

  
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwZU = dwMaster;
        }
    }
}
